package com.jiaquyun.jcyx.db;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import org.jetbrains.annotations.NotNull;

import java.util.List;

@Dao
public interface CartSelectedDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Long insert(@NotNull CartSelected account);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(@NotNull List<CartSelected> accounts);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void update(@NotNull CartSelected account);

    @Delete
    void delete(@NotNull CartSelected account);

    @Query("DELETE FROM CartSelected")
    void delete();

    @Query("DELETE FROM CartSelected WHERE shop_id = :shopId and cart_id =:cartId")
    void delete(int shopId, int cartId);

    @Query("DELETE FROM CartSelected WHERE shop_id = :shopId")
    void delete(int shopId);


    @Query("SELECT * FROM CartSelected")
    List<CartSelected> loadAll();

    @Query("SELECT * FROM CartSelected WHERE id =:id")
    CartSelected selectCartSelectedByID(int id);

    @Query("SELECT * FROM CartSelected WHERE shop_id=:shopId")
    List<CartSelected> selectCartSelectedByShopId(int shopId);

    @Query("SELECT * FROM CartSelected WHERE shop_id=:shopId AND cart_id=:cartId")
    CartSelected selectCartSelectedByShopIdAndCartId(int shopId, int cartId);

}
